/**
 * http://usejsdoc.org/
 */
var util = require("util"),
	events = require("events");

/**构造函数，目的为了继承events.EventEmitter方法属性*/
function MyStream(){
	events.EventEmitter.call(this);
}

/**使用util中的inherits来实现MyStream继承EventEmitter*/
util.inherits(MyStream, events.EventEmitter);

/**为MyStream添加方法*/
MyStream.prototype.write = function(data){
	this.emit("data",data);
};

var stream = new MyStream();
/**判断是否继承events.EventEmitter*/
console.log(stream instanceof events.EventEmitter); //true
/**通过super_获取父类对象*/
console.log(MyStream.super_ === events.EventEmitter);//true

/**继承来自events.EventEmitter的方法*/
stream.on("data", function(data) {
	console.log('Received data: "'+ data +'"');
});

stream.write("It's works!");//received data:"It's works!"